package com.criteria.filter.implextend;

import com.criteria.filter.PersonCriteria;
import com.criteria.po.Person;

import java.util.Arrays;
import java.util.List;

public class PersonAndCriteria implements PersonCriteria {

    private List<PersonCriteria> criteria;

    public PersonAndCriteria(PersonCriteria ... criteria) {
        this.criteria = Arrays.asList(criteria);
    }

    @Override
    public List<Person> streamFilterCollect(List<Person> persons) {
        List<Person> personSet = persons;
        for ( PersonCriteria c : criteria ) {
            personSet = c.streamFilterCollect(personSet);
        }
        return personSet;
    }

}
